//
//  ZYSignInCell.m
//  优学荟管理系统
//
//  Created by edz on 2017/12/9.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "ZYSignInCell.h"
#import "ZYSignInModel.h"
@implementation ZYSignInCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setUpSuperView];
    }
    
    return self;
    
    
}


- (void)assignByZYSignInModel:(ZYSignInModel *)model{
    
    
    
    BOOL isUp = [NSString isBlankString:model.lessonName];
    
    if (isUp) {
        self.couseLabel.text = @"签到课程：";
    }else{
        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"签到课程：%@",model.lessonName]];
        NSRange range1 =[[AttributedStr string]rangeOfString:[NSString stringWithFormat:@"%@",model.lessonName]];
        [AttributedStr addAttribute:NSForegroundColorAttributeName value:ColorRGB(102, 102, 102) range:range1];
        
        self.couseLabel.attributedText = AttributedStr;
    }
    
    
    
    BOOL isUpTow = [NSString isBlankString:model.recordTime];
    
    if (isUpTow) {
        
        self.timeLabel.text = @"签到时间：";
        
    }else{
      
        NSMutableAttributedString *AttributedStrTow = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"签到时间：%@",model.recordTime]];
        NSRange rangeTow =[[AttributedStrTow string]rangeOfString:[NSString stringWithFormat:@"%@",model.recordTime]];
        [AttributedStrTow addAttribute:NSForegroundColorAttributeName value:ColorRGB(102, 102, 102) range:rangeTow];
        
        self.timeLabel.attributedText = AttributedStrTow;
        
        
    }
    
    
    
    BOOL isUpThree = [NSString isBlankString:model.childName];
    
    if (isUpThree) {
        
        self.personLabel.text = @"签到人：";
        
    }else{
        
        NSMutableAttributedString *AttributedStrThree = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"签到人：%@",model.childName]];
        NSRange rangeThree =[[AttributedStrThree string]rangeOfString:[NSString stringWithFormat:@"%@",model.childName]];
        [AttributedStrThree addAttribute:NSForegroundColorAttributeName value:ColorRGB(102, 102, 102) range:rangeThree];
        
        self.personLabel.attributedText = AttributedStrThree;
        
        
    }
    
    
    
    
   
    
    
    
    
    if (0 == [model.status integerValue]) {//签到
        
        [self.typeButton setImage:[UIImage imageNamed:@"bg_class"] forState:(UIControlStateNormal)];
    }else if (1 == [model.status integerValue]){//缺勤
        [self.typeButton setImage:[UIImage imageNamed:@"bg_absence"] forState:(UIControlStateNormal)];

    }else{//请假
        [self.typeButton setImage:[UIImage imageNamed:@"bg_vacation"] forState:(UIControlStateNormal)];

        
    }
    
    
    
    
}



- (void)setUpSuperView{
    
    
    self.couseLabel = [UILabel new];
    self.couseLabel.font = [UIFont systemFontOfSize:15];
    self.couseLabel.textColor = ColorRGB(153, 153, 153);
    [self.contentView addSubview:self.couseLabel];
    
    
    self.timeLabel = [UILabel new];
    self.timeLabel.font = [UIFont systemFontOfSize:15];
    self.timeLabel.textColor = ColorRGB(153, 153, 153);
    [self.contentView addSubview:self.timeLabel];
    
    
    self.personLabel = [UILabel new];
    self.personLabel.font = [UIFont systemFontOfSize:15];
    self.personLabel.textColor = ColorRGB(153, 153, 153);
    [self.contentView addSubview:self.personLabel];
    
    
    
    self.typeButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.typeButton.titleLabel.font = [UIFont systemFontOfSize:15];
    self.typeButton.layer.cornerRadius = (kScreenWidth *95/750)/2;
    self.typeButton.clipsToBounds = YES;
    
    [self.contentView addSubview:self.typeButton];
    
    
    
    
    
    self.couseLabel.text = @"zhangyu";
    [self.couseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(kScreenWidth * 30/750);
    }];
    
    self.timeLabel.text = @"2015.22";
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.couseLabel);
        make.top.equalTo(self.couseLabel.mas_bottom).offset(kScreenHeight *30/1334);
        
    }];
    
    self.personLabel.text = @"sljgsljglds";
    [self.personLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeLabel);
        make.top.equalTo(self.timeLabel.mas_bottom).offset(kScreenHeight *30/1334);
    }];
    
    
    [self.typeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self);
        make.width.height.offset(kScreenWidth * 95/750);
        make.right.equalTo(self).offset(-kScreenWidth *30/750);
        
    }];
    
    
    UILabel *lineLabel = [UILabel new];
    lineLabel.backgroundColor = ColorRGB(247, 245, 245);
    [self.contentView addSubview:lineLabel];
    
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.offset(0);
        make.top.equalTo(self.personLabel.mas_bottom).offset(kScreenHeight *30/1334);
        make.width.offset(kScreenWidth);
        make.height.offset(kScreenHeight *30/1334);
        
    }];
    
    
    
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
        make.bottom.equalTo(lineLabel).offset(0);
    }];
    
    
}


















@end
